
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws IOException {
		int n = 1000001;
		int[] phi = new int[n];
		for (int i = 0; i < n; i++)
			phi[i] = i;

		for (int i = 2; i < n; i++) {
			if (phi[i] < i)
				continue;
			phi[i]--;
			for (int j = 2 * i; j < n; j += i)
				phi[j] -= phi[j] / i;
		}
		long[] sums = new long[n];
		for (int i = 2; i < n; i++)
			sums[i] = (long) sums[i - 1] + (long) phi[i];

		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		int t = Integer.parseInt(in.readLine());
		while (t-- > 0) {
			int a = Integer.parseInt(in.readLine());
			System.out.println(sums[a]);
		}

	}

}